import jpush


class JPush:
    app_key = '79c779c3fb75c7696eca5614'
    master_key = '8c75df48c45626f16dc71f26'

    @classmethod
    def create_push(cls):
        _jpush = jpush.JPush(cls.app_key, cls.master_key)
        return _jpush.create_push()

    @classmethod
    def send_push(cls, alias, title, msg_content, alert=None, content_type=None, extra=None, channel_id=None):
        push = JPush.create_push()
        push.audience = jpush.audience(jpush.alias(*alias))
        if alert:
            android = jpush.android(alert=alert, title=title, channel_id=channel_id)
            push.notification = jpush.notification(alert=alert, android=android)
        push.platform = jpush.all_
        push.message = jpush.message(msg_content=msg_content, title=title, content_type=content_type, extras=extra)
        push.send()
